package com.eagle.coders.security.beans;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.eagle.coders.common.bean.annotations.ResourceKey;
import com.eagle.coders.common.bean.annotations.UiComponentPosition;
import com.eagle.coders.common.bean.annotations.UnBound;


/**
 * @author Anees
 *
 */
@Entity
@Table(name ="eagle_ranks")
@SequenceGenerator(name="rank_gen_seq", sequenceName="eagle_gen_seq")
public class RanksBean implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private Integer id;
	
	private Double rankId;
	
	private String rank;
	
	private String description;
	
	private List<RanksFunctionAccessBean> rankFunctionsAccessBeans;
	

	/**
	 * @return the id
	 */
	@Id
	@ResourceKey(key="bean.ranks.id")
	@GeneratedValue(generator="rank_gen_seq", strategy=GenerationType.SEQUENCE)
//	@UnBound
	public Integer getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @return the rankId
	 */
	@UiComponentPosition(positionColumn="1", positionRow="1", tableDisplayColumn="1")
	@Column(name = "rankId")
//	@UnBound
	@ResourceKey(key="bean.ranks.rankid")
	public Double getRankId() {
		return rankId;
	}

	/**
	 * @param rankId the rankId to set
	 */
	public void setRankId(Double rankId) {
		this.rankId = rankId;
	}

	/**
	 * @return the rank
	 */
	@ResourceKey(key="bean.ranks.rank")
	@UiComponentPosition(positionColumn="1", positionRow="2", tableDisplayColumn="2")
	@Column(name = "rank", length = 10)
	public String getRank() {
		return rank;
	}

	/**
	 * @param rank the rank to set
	 */
	public void setRank(String rank) {
		this.rank = rank;
	}

	/**
	 * @return the description
	 */
	@ResourceKey(key="bean.ranks.description")
	@UiComponentPosition(positionColumn="1", positionRow="4", tableDisplayColumn="3")
	@Column(name = "description", length = 50)
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the rankFunctionsAccessBeans
	 */
	@ResourceKey(key="bean.ranks.rank.function")
	@UiComponentPosition(positionColumn="1", positionRow="3", tableDisplayColumn="-1")
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, targetEntity = RanksFunctionAccessBean.class, mappedBy = "rank")
	public List<RanksFunctionAccessBean> getRankFunctionsAccessBeans() {
		return rankFunctionsAccessBeans;
	}

	/**
	 * @param rankFunctionsAccessBeans the rankFunctionsAccessBeans to set
	 */
	public void setRankFunctionsAccessBeans(
			List<RanksFunctionAccessBean> rankFunctionsAccessBeans) {
		this.rankFunctionsAccessBeans = rankFunctionsAccessBeans;
	}
}